#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
#define ll long long
ll n;
ll a[N];
ll ans=0;
ll sum[N];
ll sz[N],szz[N];
ll cnt=0;
bool vis[N];

int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%lld",&n);
    ans=n;
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n);
    cnt++;
    sz[cnt]++;
    ll last=a[1];
    for(int i=2;i<=n;i++){
        if(a[i]==last){
            sz[cnt]++;
        }else{
            cnt++;
            sz[cnt]++;
            last=a[i];
        }
    }
    sum[0]=0;
    for(int i=1;i<=n;i++){
        sum[i]=sum[i-1]+sz[i];
    }
    ll cntt=sum[1]+1;
    for(int i=1;i<=cnt;i++){
        if(cntt<=sum[i]) cntt=sum[i]+1;
        ll llst=n-cntt+1;
        if(cntt>n) break;
        if(sz[i]<=llst){
            ans-=sz[i];
            cntt+=sz[i];
            if(cntt>n) break;
        }else{
            ans-=llst;
            break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}